package org.bean2sql.jdbc;

import java.sql.Connection;
import java.util.List;
import java.util.Map;

/**
 * 
 * Provides a set of SQL instructions that will be executed by the JDBC connection.
 * 
 * @author Gyowanny Queiroz
 * 
 */
public interface JdbcAccessor {

    /**
     * Sets the current application's connection
     * @param con
     */
    void setConnection(Connection con);
    
    /**
     * Retrieves all the beans stored in the given class table. This method
     * executes a "Select * from [beanClass]".
     * 
     * @param beanClass
     * @return Object collection
     */
    List<Object> getAll(Class beanClass);

    /**
     * Retrieves all the beans stored in the given class table that are 
     * expected in the whereClause. 
     * This method executes a "Select * from [beanClass] where [whereClause]".
     * 
     * @param beanClass
     * @param whereClause
     * @return Object collection
     */
    List<Object> getAll(Class beanClass, String whereClause);

    /**
     * Retrieves a bean with the given pkFields.
     * (e.g. Select * from [beanClass] where [pkFields1 = values1] ... and [pkFieldsN = valuesN])  
     * @param beanClass
     * @param pkFields
     * @return
     */
    Object getByPk(Class beanClass, Map<String,String> pkFieldsAndValues);

}
